<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<base href="<%=request.getContextPath()%>\">
<link rel="stylesheet" type="text/css" href="css/header.css" />
<script src="js/jquery-2.2.3.min.js" type="text/javascript"
	charset="utf-8"></script>
<script src="js/headerjs.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
//进入购物车判断是否登陆
	$(function(){
		shoppingheader();
		shoppingright();
	})
function shoppingheader() {

	$(".cart").click(function(){
		var liji=$(this);
		$.ajax({
			type:"post",
			url:"shouye",
			data:"v=islogin",
			success:function(msg){
				console.log(msg);
				if(msg=="true"){
					window.location.href="gwc";
				}
				if(msg=="false"){
					$(".loginss").show();
				}
			}
		})
		
	})
}

function shoppingright() {
	$(".right-cart").click(function(){
		var liji=$(this);
		$.ajax({
			type:"post",
			url:"shouye",
			data:"v=islogin",
			success:function(msg){
				console.log(msg);
				if(msg=="true"){
					window.location.href="gwc";
				}
				if(msg=="false"){
					$(".loginss").show();
				}
			}
		})
		
	})
}
</script>
<script type="text/javascript" charset="utf-8">
	$(function() {
		//监听文本框的回车事件
		$(':input,:password').keydown(function() {
			var code = event.keyCode;
			if (code == 13) {
				$(".loginform .loginbox").submit();
			}
		})
		$(".loginups :input").on("input", function() {
			//验证表单信息
			var telphones = $.trim($(".dianhuaone").val());
			var pwds = $.trim($(".mimasone").val());
			console.log("注册电话是" + telphones);
			console.log("注册i密码是" + pwds);

			if (telphones == "") {
				$(".tipsthree").html("电话号码不能为空");
				$(".tipsthree").css("display", "block");
				return false;
			} else if (pwds == "") {
				$(".tipsfour").html("密码不能为空");
				$(".tipsfour").css("display", "block");
				return false;
			} else if (isPhoneNo(telphones) == false) {
				$(".tipsthree").html("请输入正确的手机号");
				$(".tipsthree").css("display", "block");
				return false;
			} else if (pwds.length != 6) {
				$(".tipsfour").html("请输入正确的六位密码");
				$(".tipsfour").css("display", "block");
				return false;
			}

			if (telphones != "") {
				$(".tipsthree").css("display", "none");
			}
			if (pwds != "") {
				$(".tipsfour").css("display", "none");
			}
			if (isPhoneNo(telphones) == true) {
				$(".tipsthree").css("display", "none");
			}
			if (pwds.length == 6) {
				$(".tipsfour").css("display", "none");
			}
			return true;
		})

		function isPhoneNo(phone) {
			var pattern = /^1[3-9]+\d{9}$/;
			return pattern.test(phone);
		}
	})
</script>

<script type="text/javascript" charset="utf-8">
	$(function() {
		//监听文本框的回车事件
		$(':input,:password').keydown(function() {
			var code = event.keyCode;
			if (code == 13) {
				$(".loginform .loginbox").submit();
			}
		})
		$(".loginss :input").on("input", function() {
			//验证表单信息
			var telphone = $.trim($(".dianhua").val());
			var pwd = $.trim($(".mimas").val());
			console.log("电话是" + telphone);
			console.log("密码是" + pwd);

			if (telphone == "") {
				$(".tipsone").html("电话号码不能为空");
				$(".tipsone").css("display", "block");
				return false;
			} else if (pwd == "") {
				$(".tipstwo").html("密码不能为空");
				$(".tipstwo").css("display", "block");
				return false;
			} else if (isPhoneNo(telphone) == false) {
				$(".tipsone").html("请输入正确的手机号");
				$(".tipsone").css("display", "block");
				return false;
			} else if (pwd.length != 6) {
				$(".tipstwo").html("请输入正确的六位密码");
				$(".tipstwo").css("display", "block");
				return false;
			}

			if (telphone != "") {
				$(".tipsone").css("display", "none");
			}
			if (pwd != "") {
				$(".tipstwo").css("display", "none");
			}
			if (isPhoneNo(telphone) == true) {
				$(".tipsone").css("display", "none");
			}
			if (pwd.length == 6) {
				$(".tipstwo").css("display", "none");
			}

			return true;
		})

		function isPhoneNo(phone) {
			var pattern = /^1[3-9]+\d{9}$/;
			return pattern.test(phone);
		}
	})
</script>

<script type="text/javascript">
	$(function() {
		$.ajax({
			type:"post",
			url:"shouye",
			data:"v=geheadtype",
			success:function(msg){
				console.log(msg);
				msg.forEach((v,i)=>{
					console.log(v.lname)
					$("#before").before(
					"<div class='homes'>"+	
					"<a href='classpage?v=fujiallgoods&lid="+msg[i].lid+"'>"+v.lname+"</a>"+"</div>"
					)
					
				})
			}
		})

		//登陆后用户名的点击事件在Ajax里面把HTML代码拼接a标签里面的hrefru
		$(".loginqh").click(function() {
			$(".dropdown-menu").slideToggle(500);
		})

		//登陆事件
		$("#denglu").click(
				function() {
					//获取电话号码和密码
					var phone = $.trim($('.dianhua').val());
					var pwd = $.trim($('#pwd').val());
					$.ajax({
						type : "post",
						url : "shouye",
						data : "v=loginin&telphone=" + phone + "&pwd=" + pwd,
						success : function(msg) {
							console.log(msg.res);
							if (msg.res == "true") {
								/* alert("dlcg"); */
								$('.loginok').hide();
								$('.loginup').hide();
								$('.loginqh').show().find("a").html("欢迎你," + msg.user.uname);
								$('.loginss').hide();
								
								//登陆成功

							}
							if (msg.res == "false") {
								//登陆失败
								/* alert("dlsb"); */
								$('.loginss').show();
								$(".tipsone").show().text(
										msg.tipsone);
								$(".tipstwo").show().text(
											msg.tipsone);	
							}
						}
					});

				})

	})
</script>
<script type="text/javascript">
	$(function() {
		//注册事件
		$("#zhucm")
				.click(
						function() {
							//获取电话号码和密码
							console.log($('.dianhuaone'));
							var phone = $.trim($('.dianhuaone').val());
							var pwd = $.trim($('#zcpwd').val());
							var codes = $.trim($('.pcin').val());
							console.log(codes + "验证码是")
							console.log(pwd);
							$
									.ajax({
										type : "post",
										url : "shouye",
										data : "v=register&telphone=" + phone+ "&pwd=" + pwd + "&codes="+ codes,
										/* data:"v=register, */
										success : function(msg) {
											if (msg.res == "true") {
												//注册成功
												/* alert("zccg") */;
												$('.loginok').hide();
												$('.loginup').hide();
												$('.loginqh').show().find("a").html("欢迎你,"+ msg.user.uname);
												$('.loginups').hide();
												$(".yzyzma").addClass("right")
														.text("√手机验证码正确");
											}
											if (msg.res == "false") {
												//注册失败
												/* alert("zcsb"); */
												$('.loginups').show();
													
												$(".tipsthree").show().text(
														msg.tipsone);
												$(".tipsfour").show().text(
														msg.tipsone);
												console.log(msg.tipsone);
												$(".yzyzma").addClass("rights")
														.text(msg.tipstwo);
											}
										}
									})
						})

	})
</script>
<script type="text/javascript">
	function checkMobileCode() {
		var $m_code = $(event.target);
		console.log("注册码是前台" + $m_code.val());
		$.ajax({
			url : "shouye",
			type : "post",
			data : {
				"v" : "check_mobile_code",
				"mcode" : $m_code.val()
			},
			success : function(d) {
				if (d.msg) {
					$(".yzyzma").addClass("right").text("√手机验证码正确");
					/* $m_code.next('.tips').addClass("right").text("√手机验证码正确"); */
					return true;
				} else {
					$(".yzyzma").addClass("rights").text("×验证码失效或错误"); 
					return false;
				}
			}
		})
	}
	//发送短信验证码的方法
	function get_mobile_code() {
		var obj = event.target;
		var tel = jQuery.trim($('#mobile').val());
		/* 			console.log("注册的手机号是："+tel)
		 */if (!tel) {
			$(".tipsthree").html("请输入你要的手机号码！！")
			/* $(obj).prev().html("请输入手机号码！！"); */
			return;
		}
		 sendemail();
		//此处使用的是ajax提交当中的post提交方式，详细请参考帮助文档
		$.post('shouye?v=sms', {
			mobile : jQuery.trim($('#mobile').val())
 		}, function(data) {
			if (data.msg && data.msg == "提交成功") {
				$(".yzyzma").addClass("right").text("√ 验证码已发送");
				/* 	$(obj).prev().addClass("right").text("√ 验证码已发送"); */
				RemainTime();
			} else {
				$(".yzyzma").addClass("rights").text("× 验证码发送失败");
				/* $(obj).prev().removeClass("right").text("× 验证码发送失败"); */
			}
		});
	};
</script>


<script>
	$(function() {
		
		$(".loginss .soon").click(function(){
			$(".loginups").css("display","block");
			$(".loginss").ss("display","none");
		})
		
		$(".loginups .zhijei").click(function(){
			$(".loginups").css("display","none");
			$(".loginss").css("display","block");
		})
		
	})
	var countdown=60; 

	function sendemail() {
		var obj = $("#djishi");
		settime(obj);
	}
	function settime(obj) { //发送验证码倒计时
		if (countdown == 0) {
			obj.attr('disabled', false);
			//obj.removeattr("disabled"); 
			obj.val("获取验证码");
			countdown = 60;
			$(".tabfocus").css("background-color","#eee");
			return;
		} else {
			obj.attr('disabled', true);
			obj.val("(" + countdown + ")秒后重发");
			$(".tabfocus").css("background-color","#8f8b8b");
			countdown--;
		}
		setTimeout(function() {
			settime(obj)
		}, 1000)
	}
</script>
<style type="text/css">
		.tips {
			padding-left: 2px;
			color: red;
		}
		
		.right {
			color: green;
		}
		
		.rights {
			color: red;
		}
		.zhijei,.soon{
			float: right;
		    position: relative;
		    top: -20px;
		    cursor: pointer;
		    
		}
		.zhijei:hover{
			color:#b4a078;
		}
		
		.soon:hover{
			color:#b4a078;
		}
		.pcbtn .tabfocus:hover{
				color:#b4a078;
				cursor: pointer;
		}
</style>
</head>
<body>
	<!-- 头部上面 -->
	<div class="headbox">
		<div id="header">
			<div class="content">
				<div class="contents">
					<a>康佳新闻</a> <span class="geka">|</span> <a>加入康佳</a> <span
						class="geka">|</span> <a>校园招聘</a> <span class="geka">|</span> <a>康佳社区</a>
					<span class="geka">|</span> <a>大宗采购</a> <span class="geka">|</span>
					<a>积分商城</a> <span class="geka">|</span>
				</div>

				<div class="cart">
					<a class="iconImg" > <img class="shopcart"
						src="imgs/chenimgs/top-header-cart.png"> 购物车(<span
						class="cart-num">0</span>) <span class="sp-num"
						style="display: none"></span>
					</a>
				</div>

				<div class="login" style="display: ${empty admin?'block':'none'}">
					<a class="loginok">登陆</a> <a class="loginup">注册</a>
				</div>
				<div class="login">
					<ul class="dropdown-menu">
						<li><a href="huiyuan"> 个人中心</a></li>
						<li><a href="diangdan">我的订单</a></li>
						<li><a href="shouye?v=loginup" class="tuichu">退出登录</a></li>
					</ul>
				</div>
				<div class="loginqh" style="display:${empty admin?'none':'block'}">
					<a>欢迎你，${admin.uname}</a>
				</div>

			</div>
		</div>
		<!-- 头部下面 -->
		<div class="sitheader" id="nav-top">
			<div class="sitheader-pos">

				<div class="rs">
					<div class="logos">
						<a style="border: solid 1px #f4f4f4"> <img
							src="imgs/chenimgs/logo.png">
						</a>
					</div>

					<div class="homes" id="fuji">
						<a href="shouye">首页</a>
					</div>
				
					

					<!-- <div class="homes">
						<a>冰箱</a>
					</div>

					<div class="homes">
						<a>洗衣机</a>
					</div>

					<div class="homes">
						<a>生活电器</a>
					</div>

					<div class="homes">
						<a>智能硬件</a>
					</div>
					<div class="homes">
						<a>智能终端</a>
					</div>
					<div class="homes">
						<a>K迷优品</a>
					</div>
					<div class="homes">
						<a>大宗采购</a>
					</div> -->
					<div class="homes" id="before">
						<a>服务</a>
					</div>

					<div class="homes">
						<a class="Magnifier " style="border: solid 1px #f4f4f4"> <img
							src="imgs/chenimgs/header-scrae.png">
						</a>
					</div>
				</div>
				<!-- 搜索 -->
				<div class="rs search" style="display: none;">
					<form action="classpage?v=selectnamemohu" method="post">
						<div class="search-wrapper">
							<button type="submit">
								<img src="imgs/chenimgs/header-scrae.png">
							</button>
							<input type="text" name="cname" class="inputSearch"
								placeholder="您喜欢的商品" value="" />
							<button class="search-close">
								<img src="imgs/chenimgs/searchclose.png">
							</button>
						</div>
						<aside class="search-content">
							<section class="search-con-frame">
								<ul id="animateUl" class="myMove">
									<li><a href="">电视</a></li>
									<li><a href="">冰箱</a></li>
									<li><a href="">洗衣机</a></li>
									<li><a href="">49X7</a></li>
									<li><a href="">A2</a></li>
									<li><a href="">OLED</a></li>
								</ul>
							</section>
						</aside>
					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- 右侧导航 -->
	<div class="back-top">
		<ul>
			<li class="kefu"><a href="" style="cursor: hand" target="_blank">
					<span class="glyphicon  glyphicon-kefu"></span> <span
					class="backShow">购买咨询</span>
			</a></li>
			<li><a href=""> <span class="glyphicon glyphicon-fuwu"></span>
					<span class="backShow">售后服务</span>
			</a></li>
			<li class="right-cart"><a > <span class="glyphicon glyphicon-cart"></span>
					<span class="backShow">购物车</span>
			</a></li>
			<li id="the-top"><a href=""> <span
					class="glyphicon glyphicontop"></span> <span class="backShow">回到顶部</span>
			</a></li>
		</ul>
	</div>

	<div class="loginss">
		<div class="middlogin">
			<div class="chaimg">
				<img src="imgs/chenimgs/chadiao.png">
			</div>
			<div class="phonelogin">
				<h2>手机登陆</h2>
				<a class="soon">手机快捷注册</a>
			</div>
			<div class="loginform">
				<!-- 	//shouye?v=loginin -->
				<form action="" method="">
					<div class="inputbox">
						<div class="qhonelogo">
							<div class="logoimgs"></div>
						</div>
						<div class="uinput box ">
							<input type="tel" class="dianhua" name="telphone"
								placeholder="请输入手机号" />
						</div>

					</div>
					<div class="tipsone">${tipsone }</div>

					<div class="inputbox">
						<div class="qhonelogo">
							<div class="logoimgss"></div>
						</div>
						<div class="uinput box ">
							<input type="password" class="mimas" name="pwd" id="pwd" value=""
								placeholder="请输入密码" />
						</div>
					</div>
					<div class="tipstwo">${tipsone }</div>

					<div class="loginbox">
						<input id="denglu" class="u-loginbtn btncolor tabfocus"
							type="button" value="登陆">
					</div>

				</form>
			</div>

		</div>
	</div>


	<div class="loginups">
		<div class="middlogin">
			<div class="chaimg">
				<img src="imgs/chenimgs/chadiao.png">
			</div>
			<div class="phonelogin">
				<h2>手机注册</h2>
				
				<a  class="zhijei">直接登陆</a>
				
			</div>

			<div class="loginform">

				<div class="inputbox">
					<div class="qhonelogo">
						<div class="logoimgs"></div>
					</div>
					<div class="uinput box ">
						<input type="tel" class="dianhuaone" id="mobile" name="telphone"
							placeholder="请输入手机号" />
					</div>

				</div>
				<div class="tipsthree">${tipsone }</div>

				<!-- 	
								<div class="inputbox">
									<div class="qhonelogo">
										<div class="logoimgss"></div>
									</div>
									<div class="uinput box ">
										<input width="100%" type="hidden" name="" id="" value="" placeholder="" />
									</div>
								</div>
								 -->

				<div class="yanzhenma">
					<div class="m-pcbox">
						<div class="inputbox m-mb m-pc f-fl">
							<div class="uinput box ">
								<input type="text" name="codes" class="pcin"
									onblur="checkMobileCode();" placeholder="请输入验证码" />
							</div>
						</div>
						<div class="pcbtn f-fl">
							<input type="button" id="djishi"  onclick="get_mobile_code();" class="tabfocus getsmscode" value="获取验证码"  style="font-size:10px;"  >
						</div>
					</div>
				</div>
				<div class="yzyzma"></div>
				<div class="">${tipstwo }</div>

				<div class="inputbox">
					<div class="qhonelogo">
						<div class="logoimgss"></div>
					</div>
					<div class="uinput box ">
						<input type="password" class="mimasone" name="pwd"
							id="zcpwd" value="" placeholder="请输入密码" />
					</div>
				</div>
				<div class="tipsfour">${tipsone }</div>
				<div class="loginbox">
					<input type="button" id="zhucm" value="注册"
						class="u-loginbtn btncolor tabfocus">
				</div>
				<span class="tips"></span>
			</div>

		</div>
	</div>
</body>
</html>
